package com.elangzhi.ssm.modules.receiptAddress.dao;

import com.elangzhi.ssm.model.ReceiptAddress;
import com.elangzhi.ssm.dao.LzDao;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;

/**
* 收货地址 Dao
* @author GaoXiang
* @version 1.0
*/
@Repository
public class ReceiptAddressDao extends LzDao<ReceiptAddress> {

    /**
     * 根据用户id获取用户收货地址列表
     * @param userId 用户id
     * @return 收货地址列表
     * @throws Exception 获取收货地址列表异常
     */
    public List<ReceiptAddress> listByUserId(Long userId) throws Exception {
        return arrayList("ReceiptAddressMapper.listByUserId",userId);
    }

    /**
    * 保存数据
    * @param receiptAddress 实体对象
    * @return 实体id
    * @throws Exception 数据保存异常
    */
    public Integer insert(ReceiptAddress receiptAddress) throws Exception {
        return insert("ReceiptAddressMapper.insert",receiptAddress);
    }

    /**
    * 根据 id 修改
    * @param receiptAddress 带id的实体对象
    * @return 受影响的行数
    * @throws Exception 数据修改异常
    */
    public Integer updateById(ReceiptAddress receiptAddress) throws Exception {
        return update("ReceiptAddressMapper.updateById",receiptAddress);
    }

    /**
    * 根据 id 删除
    * @param id 数据id
    * @return 受影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteById(Long id) throws Exception {
        return delete("ReceiptAddressMapper.deleteById",id);
    }

    /**
    * 根据 id 查找
    * @param id 实体id
    * @return 实体
    * @throws Exception 查询异常
    */
    public ReceiptAddress selectById(Long id) throws Exception {
        return selectOne("ReceiptAddressMapper.selectById",id);
    }

    /**
    * 根据 id 批量删除
    * @param ids 要删除的id
    * @return 影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteByIds(List<Long> ids) throws Exception {
        return delete("ReceiptAddressMapper.deleteByIds",ids);
    }

    /**
    * 查询列表
    * @param map 参数
    * @return 列表
    * @throws Exception 数据返回异常
    */
    public PageInfo<ReceiptAddress> list(Map map) throws Exception {
        return list("ReceiptAddressMapper.list",map);
    }

    /**
    * 查询列表 带分页
    * @param map 参数
    * @param page 页码
    * @param size 每页大小
    * @return 列表
    * @throws Exception 数据返回异常
    */
    public PageInfo<ReceiptAddress> list(Map map,int page,int size) throws Exception {
        return list("ReceiptAddressMapper.list",map,new RowBounds(page,size));
    }

}
